cmake_minimum_required(VERSION 3.23.0)

set(MAPLE_ROOT $ENV{MAPLE_ROOT})

set(inc_dirs
${MAPLE_ROOT}/src/mrt/sanrazor/include
${MAPLE_ROOT}/tools/gcc-linaro-7.5.0/aarch64-linux-gnu/include/c++/7.5.0
${MAPLE_ROOT}/tools/gcc-linaro-7.5.0/aarch64-linux-gnu/include/c++/7.5.0/aarch64-linux-gnu
${MAPLE_ROOT}/tools/gcc-linaro-7.5.0/aarch64-linux-gnu/libc/usr/include
${MAPLE_ROOT}/tools/gcc-linaro-7.5.0/lib/gcc/aarch64-linux-gnu/7.5.0/include
${MAPLE_ROOT}/tools/gcc-linaro-7.5.0/aarch64-linux-gnu/libc/usr/include/linux
)

set(src_libsanrazor
${MAPLE_ROOT}/src/mrt/sanrazor/src/sanrazor.c
)

add_library(sanrazor-dynamic SHARED ${src_libsanrazor})
add_library(sanrazor-static STATIC ${src_libsanrazor})

set(CMAKE_C_COMPILER ${MAPLE_ROOT}/tools/gcc-linaro-7.5.0/bin/aarch64-linux-gnu-gcc)
# set(CMAKE_CXX_COMPILER ${MAPLE_ROOT}/tools/gcc-linaro-7.5.0/bin/aarch64-linux-gnu-g++)

set_target_properties(sanrazor-dynamic PROPERTIES
  COMPILE_FLAGS "-O0 -g -nostdinc -nostdinc++ -fno-exceptions -DENABLE_MAPLE_SAN"
  INCLUDE_DIRECTORIES "${inc_dirs}"
  LINK_LIBRARIES ""
  OUTPUT_NAME "sanrazor"
)

set_target_properties(sanrazor-static PROPERTIES
  COMPILE_FLAGS "-O0 -g -nostdinc -nostdinc++ -fno-exceptions -DENABLE_MAPLE_SAN"
  INCLUDE_DIRECTORIES "${inc_dirs}"
  LINK_LIBRARIES ""
  OUTPUT_NAME "sanrazor"
)
